<template>
	<view>
		<view class="cu-custom" :style="{height: $wanlshop.wanlsys().height + 'px' }">
			<view class="cu-bar fixed" :style="{
				height: $wanlshop.wanlsys().height + 'px', 
				paddingTop: $wanlshop.wanlsys().top + 'px',
				color: '#333333',
				backgroundColor: '#fff',
			}">
				<view class="action" @tap="$wanlshop.on('/pages/index')">
					<text class="wlIcon-fanhui1"></text>
				</view>
				<view class="content text-bold" :style="{top: $wanlshop.wanlsys().top + 'px'}">
					我的
				</view>
				<view class="action" @tap="$wanlshop.on('/pages/index')">
					<text class="iconfont icon-ipr_shouye text-bold" style="font-size: 44rpx;"></text>
				</view>
			</view>
		</view>
		<!-- <view class="w100 bg-blue" style="height: 80rpx;"></view> -->
		<view class="my-header bg-white">
			<view class="plr-36 ptb-40  bb">
				<view class="flex_l" @click="goLogin">
					<image :src="$wanlshop.oss('/uploads/staticImage/img/my-head-icon.png')" mode=""></image>
					
					<view>
						<view class="size-32 ml-40">
							{{token?(userInfo.mobile?userInfo.mobile:userInfo.nickname):'登录/注册'}}
						</view>
						<view class="flex_l ml-40 mt-30"
							v-if="token&&userInfo.real_verified==1&&userInfo.driver_verified==1">
							<view class="gray-2">下班</view>
							<u-switch class="mlr-20" v-model="driver_status" @change="change"></u-switch>
							<view class="blue">上班</view>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="plr-65 ptb-35 flexz" @click="goWallet">
				<view class="text-center">
					<view class="">
						￥{{token?income||0:0}}
					</view>
					<view class="size-28 gray-2 mt-10">
						累计收入
					</view>
				</view>
				<view class="text-center">
					<view class="">
						￥{{token?money||0:0}}
					</view>
					<view class="size-28 gray-2 mt-10">
						账户余额
					</view>
				</view>
				<view class="text-center">
					<view class="">
						￥{{token?today_money||0:0}}
					</view>
					<view class="size-28 gray-2 mt-10">
						今日收入
					</view>
				</view>
			</view> -->
		</view>
		<view class="w100" style="height: 20rpx;background: #F8F8F8;"></view>
		<u-cell-item title="实名认证"
			:class="[!userInfo.real_verified?'':userInfo.real_verified==0?'':userInfo.real_verified==1?'active':userInfo.real_verified==2?'':'active']"
			:value="!token?'请登录':!userInfo.real_verified?'未申请':userInfo.real_verified==0?'待审核':userInfo.real_verified==1?'已认证':userInfo.real_verified==2?'已拒绝':'待审核'"
			:arrow="!userInfo.real_verified?true:userInfo.real_verified==0?true:userInfo.real_verified==1?false:userInfo.real_verified==2?true:false"
			@click="goIDcard">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-1.png')" mode=""></image>
				
			</view>
		</u-cell-item>
		<u-cell-item title="驾照认证"
			:class="[userInfo.driver_verified==0?'':userInfo.driver_verified==1?'active':userInfo.driver_verified==2?'active':'']"
			:value="!token?'请登录':!userInfo.driver_verified?'未申请':userInfo.driver_verified==0?'待审核':userInfo.driver_verified==1?'已认证':userInfo.driver_verified==2?'已拒绝':'待审核'"
			:arrow="!userInfo.driver_verified?true:userInfo.driver_verified==0?true:userInfo.driver_verified==1?false:userInfo.driver_verified==2?true:false"
			@click="goDriver">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-2.png')" mode=""></image>
			</view>
		</u-cell-item>
		<u-cell-item title="车主认证" 
			:class="[userInfo.card_verified==0?'':userInfo.card_verified==1?'active':userInfo.card_verified==2?'active':'']"
			:value="!token?'请登录':!userInfo.card_verified?'未申请':userInfo.card_verified==0?'待审核':userInfo.card_verified==1?'已认证':card_verified==2?'已拒绝':'待审核'"
			:arrow="!userInfo.card_verified?true:userInfo.card_verified==0?true:userInfo.card_verified==1?false:userInfo.card_verified==2?true:false"
			@click="goOwner">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-2.png')" mode=""></image>
			</view>
		</u-cell-item>
		<!-- <u-cell-item v-if="hasSF" title="车主认证"
			:class="[userInfo.card_verified==0?'':userInfo.card_verified==1?'active':userInfo.card_verified==2?'active':'']"
			:value="!token?'请登录':!userInfo.card_verified?'未申请':userInfo.card_verified==0?'待审核':userInfo.card_verified==1?'已认证':userInfo.card_verified==2?'已拒绝':'待审核'"
			:arrow="!userInfo.card_verified?true:userInfo.userInfo.card_verified==0?true:userInfo.userInfo.card_verified==1?false:userInfo.userInfo.card_verified==2?true:false"
			@click="goOwner">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-3.png')" mode=""></image>
			</view>
		</u-cell-item> -->
		<view class="w100" style="height: 20rpx;background: #F8F8F8;"></view>
		<!-- <u-cell-item v-if="hasSF" title="顺风车发布" class="active" @click="toSflist">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-4.png')" mode=""></image>
			</view>
		</u-cell-item> -->
		<u-cell-item title="我的订单" class="active" @click="goOrder">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-5.png')" mode=""></image>
			</view>
		</u-cell-item>
		<u-cell-item title="投诉订单" @click="goPro">
			<view slot="icon" class="icon img-icon mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-complaints.png')" mode=""></image>
				
			</view>
		</u-cell-item>
		<!-- <view class="flex plr-32 ptb-26" style="height: 103rpx;" @click="goPay"> -->
		<!-- <view class="flex" @click.stop="showModel=true">
				<view class="icon mr-20">
					<image :src="$wanlshop.oss('/uploads/staticImage/img/my-6.png')" mode=""></image>
				</view>
				<view class="mr-20" style="font-weight: 700;">
					平台服务费
				</view>
				<u-icon name="question-circle" color="#969799"></u-icon>
			</view> -->
		<!-- <view class="flex1 flex-middle">
				<view class="" v-if="!token">
					0
				</view>
				<view :class="[fee * 1== 0?'blue':'red','mr-5']" v-else>
					{{fee*1==0?fee:'-'+fee}}
				</view>
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view> -->
		<!-- </view> -->
		<view class="w100" style="height: 20rpx;background: #F8F8F8;"></view>
		<!-- <u-cell-item title="设置" @click="goSet">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-7.png')" mode=""></image>
			</view>
		</u-cell-item> -->
		<u-cell-item title="联系我们" @click="goContact">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-8.png')" mode=""></image>
			</view>
		</u-cell-item>
		<!-- <u-cell-item title="帮助中心" @click="goHelp">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-9.png')" mode=""></image>
			</view>
		</u-cell-item> -->
		<!-- <u-cell-item title="关于我们" @click="goAbout">
			<view slot="icon" class="icon flex1 flex-middle mr-20">
				<image :src="$wanlshop.oss('/uploads/staticImage/img/my-10.png')" mode=""></image>
			</view>
		</u-cell-item> -->
		<view class="w100" style="height: 20rpx;background: #F8F8F8;"></view>
		<!-- <pay :show="show" @money="getmoney" @close="show=false"></pay> -->
		<u-modal v-model="showModel" content="线下结算产生订单服务费,欠缴的服务费达到平台设置的限额,将无法接单"></u-modal>
		<u-tabbar v-model="currentTab" :list="listTab" active-color="#120062" @change="jump"></u-tabbar>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				fee: '', //平台服务费
				income: '', //累计收入
				money: '', //可提现金额
				today_money: '', //今日收入
				IDcard: '未认证',
				Driver: '未认证',
				Owner: '',
				show: false, //支付
				showModel: false,
				currentTab: 2, // 底部
				driver_status:false,
				listTab: [ {
						"pagePath": "/pages/driver/order/index",
						"iconPath": "/static/tabbar/2.png",
						"selectedIconPath": "/static/tabbar/2-2.png",
						"text": "订单"
					}, {
						"pagePath": "/pages/driver/message/index",
						"iconPath": "/static/tabbar/5.png",
						"selectedIconPath": "/static/tabbar/5-1.png",
						"text": "消息"
					},
					{
						"pagePath": "/pages/driver/my/index",
						"iconPath": "/static/tabbar/3.png",
						"selectedIconPath": "/static/tabbar/3-3.png",
						"text": "我的"
					}
				], // 底部
			}
		},
		computed: {
			...mapState(['userInfo', 'token', 'tabList']),

			hasSF() {
				let a = false
				this.tabList.forEach(item => {
					if (item.id == 1) a = true
				})
				return a
			},
			hasDJ() {
				let a = false
				this.tabList.forEach(item => {
					if (item.id == 0) a = true
				})
				return a
			},
		},
		onLoad() {},
		onShow() {
			console.log("6666", this.token, this.userInfo)
			// if (this.token) {
			this.$store.dispatch('updateUserInfo')
			this.getmoney()
			this.driver_status = this.userInfo.driver_status == 1 ? true : false
			// }
		},
		methods: {
			//投诉进度
			goPro() {
				uni.navigateTo({
					url: '/pages/driver/my/progress'
				})
			},
			jump(e) {
				console.log(e)
				uni.navigateTo({
					url: this.listTab[e].pagePath
				})
			},
			change(status) {
				console.log(status);
				this.$http('/addons/ddrive/user/driver_status', {
					status: status ? 1 : 2
				}, "POST").then(data => {
					this.$store.dispatch('updateUserInfo')
				})
			},
			toSflist() {
				uni.navigateTo({
					url: "/pages/driver/shunfeng/pub-list"
				})
			},
			goLogin() {
				if (!this.token) {
					uni.navigateTo({
						// url: '/pages/driver/login/index'
						url: '/pages/user/auth/name'
					})
				}
			},
			goPay() {
				if (parseFloat(this.fee) > 0) {
					this.show = true
				}
			},
			goWallet() { //钱包
				if (this.token) {
					uni.navigateTo({
						url: '/pages/driver/my/wallet'
					})
				} else {
					uni.showToast({
						title: '请登录',
						icon: 'none'
					})
				}
			},
			goIDcard() { //实名认证
				// if (!this.userInfo.real_verified || this.userInfo.real_verified == 0 || this.userInfo.real_verified == 2) {
				// 	uni.navigateTo({
				// 		url: '/pages/driver/my/IDcard'
				// 	})
				// }
				if (!this.userInfo.real_verified) {
					uni.navigateTo({
						url: '/pages/transport/my/IDcard'
					})
				} else if (this.userInfo.real_verified == 2) {
					uni.showToast({
						title: '审核失败，请重新上传',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/transport/my/IDcard'
						})
					}, 2000)

				} else if (this.userInfo.real_verified == 0) {
					uni.showToast({
						title: '审核中，请耐心等待..',
						icon: 'none'
					})
				} else {
					uni.navigateTo({
						url: '/pages/transport/my/IDcard-success'
					})
				}
			},
			goDriver() { //驾照认证
				if (this.userInfo.driver_verified == 0 || this.userInfo.driver_verified == 2 || !this.userInfo
					.driver_verified) {
					uni.navigateTo({
						url: '/pages/driver/my/Driver'
					})
				}
			},
			goOwner() { //车主认证
				if (this.userInfo.card_verified == 0 || !this.userInfo.card_verified == 2 || !this.userInfo
					.card_verified) {
					uni.navigateTo({
						url: '/pages/driver/my/owner/index'
					})
				}
			},
			goOrder() { //订单
				uni.navigateTo({
					url: '/pages/driver/my/my-order'
				})
			},
			goSet() { //设置
				uni.navigateTo({
					url: '/pages/driver/my/set/index'
				})
			},
			goContact() { //联系我们
				uni.navigateTo({
					url: '/pages/driver/my/contact'
				})
			},
			goHelp() { //帮助中心
				uni.navigateTo({
					url: '/pages/driver/my/help/index'
				})
			},
			goAbout() { //关于我们
				uni.navigateTo({
					url: '/pages/driver/my/about'
				})
			},
			// 我的收入
			getmoney() {
				this.$http('/addons/ddrive/user/userIncome', "POST").then(data => {
					console.log(data);
					this.money = parseFloat(data.money).toFixed(2)
					this.income = parseFloat(data.income).toFixed(2)
					this.today_money = parseFloat(data.today_income).toFixed(2)
					this.fee = data.platform_service_fee
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-header {
		margin-top: -20rpx;
		border-radius: 10rpx 10rpx 0 0;

		image {
			width: 104rpx;
			height: 104rpx;
		}
	}

	.left {
		height: 42rpx;
	}

	.icon {
		image {
			width: 42rpx;
			height: 42rpx;
		}
	}

	.active {
		/deep/.u-cell__value {
			color: $blue;
		}
	}

	.red {
		/deep/.u-cell__value {
			color: $red;
		}
	}
</style>